package com.itheima.tanhua.dubbo.api;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.tanhua.dubbo.mapper.UserMapper;
import com.itheima.tanhua.model.domain.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class UserApiImpl implements UserApi{

    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByPhone(String phone) {
        LambdaQueryWrapper<User> lwq = new LambdaQueryWrapper<>();
        lwq.eq(User::getMobile,phone);

        User user = userMapper.selectOne(lwq);

        return user;
    }

    @Override
    public Long save(User user) {

        userMapper.insert(user);

        return user.getId();
    }
}
